package ro.gillardon.persistence.document.model;

import com.orientechnologies.orient.core.record.impl.ODocument;

/**
 * Contains methods and details specific to a hotel reservation (hotel details and number of days spent there).
 *
 * @author haiurar
 */
public class HotelReservation extends ODocumentClass {
  private static final String NR_DAYS = "nrDays";
  private static final String HOTEL_DETAILS = "hotelDetails";
  private static final String PRICE = "price";
  private static final String DATE = "date";
  private static final String NAME = "name";
  private static final String LOCATION = "location";
  private static final String DAY_TYPE = "dayType";
  private static final String ROOM_TYPE = "roomType";
  private static final String HOTEL_DETAILS_CLASS = "HotelDetails";

  /**
   * Instantiates a new hotel reservation.
   *
   * @param hotelDetails the hotel details of the current reservation
   * @param nrDays the number of days
   */
  public HotelReservation(final HotelDetails hotelDetails, final int nrDays) {
    super();
    ODocument hotelDetailsDocument = new ODocument(HOTEL_DETAILS_CLASS);
    hotelDetailsDocument.field(ROOM_TYPE, hotelDetails.getRoomType());
    hotelDetailsDocument.field(DAY_TYPE, hotelDetails.getDayType());
    hotelDetailsDocument.field(LOCATION, hotelDetails.getLocation());
    hotelDetailsDocument.field(NAME, hotelDetails.getName());
    hotelDetailsDocument.field(DATE, hotelDetails.getDate());
    hotelDetailsDocument.field(PRICE, hotelDetails.getPrice());
    this.doc.field(HOTEL_DETAILS, hotelDetailsDocument);
    this.doc.field(NR_DAYS, nrDays);
  }

  /**
   * Gets the hotel details.
   *
   * @return the hotel details
   */
  public HotelDetails getHotelDetails() {
    return this.doc.field(HOTEL_DETAILS);
  }

  /**
   * Gets the number of days.
   *
   * @return the number of days
   */
  public int getNrDays() {
    return this.doc.field(NR_DAYS);
  }
}
